package com.czk.netty.netty.tcp.protocaltcp.practice.server;

import com.czk.netty.netty.tcp.protocaltcp.practice.client.MessageEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/8 11:56
 */
public class ServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        ChannelPipeline pipeline = channel.pipeline();
        // 解码器
        pipeline.addLast(new MessageEncoder());
        // 编码器
        pipeline.addLast(new MessageDecoder());
        // 处理器
        pipeline.addLast(new ServerHandler());
    }
}
